import { useSelector, useDispatch } from "react-redux";
import numStore from "@/store/modules/numStore";
const View = () => {
  const num = useSelector((state: RootState) => state.moduleNumReducer.num);
  const arr = useSelector((state: RootState) => state.noduleArrReducer.arr);
  const dispatch = useDispatch();
  const changeNum = () => {
    dispatch({ type: "addPage1" });
  };
  const changeNum2 = () => {
    //异步写法
    // @ts-ignore
    // dispatch((dis:Function)=>{
    //   setTimeout(()=>{
    //     dis({type:"addPage1"})
    //   },1000)
    // })
    dispatch(numStore.asyncActions.asyncAddPage1);
  };
  return (
    <div className="page1">
      <p>page1组件</p>
      <p>{num}</p>
      <p>{arr}</p>
      <button onClick={changeNum}>通不按钮</button>
      <button onClick={changeNum2}>异步按钮</button>
    </div>
  );
};

export default View;
